<?php

namespace App\Model;

use Illuminate\Http\Request;

class RoomVoiceCheckLogs extends BaseModel
{
    protected $table = 'room_voice_check_logs';
    
    public function getList(Request $request) {
        $page = $request->get('page', 1);
        $limit = $request->get('limit', 10);
        $status = $request->get('status') ?? 0;
        $illegal_desc = $request->get('illegal_desc') ?? '';
        $query = new RoomVoiceCheckLogs();
        if($status != 3){
            $query = $query->where('status', '=', $status);
        }
        if($illegal_desc != ''){
            $query = $query->where('illegal_desc', '=', $illegal_desc);
        }

        return $query->with(['room:room_id,name,room_uid','user:user_id,nickname,uuid'])
            ->orderBy('id','DESC')
            ->paginate($limit,'*','page', $page);
    }
    
    public function user() {
        return $this->hasOne(Number::class,'user_id','user_id');
    }
    
    public function room() {
        return $this->hasOne(Room::class,'room_id','room_id');
    }
}
